Trigger on object creation/modification

We want to have a "Default CR" module-level attribute, which will be used to fill-in a "CR" object-level attribute whenever the object is created or modified.  I tried setting up a trigger (Trigger crtrig = trigger("crtrig", project->all->module->all->formal->object->all, pre, open, 10, "#include <triggers/crtrigger>")) but it's not firing correctly.

IS there a way to do what we want, with triggers or differently?


ronwis - Thu May 23 14:37:33 EDT 2013

Re: Trigger on object creation/modification
llandale - Thu May 23 16:42:08 EDT 2013

It sounds like you should just change the attribute definition to have what you want for it's default value.

As for Triggers: Ha!  I'm sure you need a "post" trigger, not a "pre".  Pre means before the event occurs, and the trigger can prevent the event.  Also, I think you should use "Trigger trg = current; Object oCurr = object(trg)" instead of "Object oCurr = current".

seems to me a year ago someone finally came up with a tolerable substistute for an object-create trigger; which took advantage of the fact that the new objects becomes current and therefore fires an object-sync trigger.  A "New" object has the characteristic "new(Object)" and have no actual attribute values.

Mmmm, I never noticed an "Object-Open" trigger before!  I wonder if it is just an Object-Sync trigger?

-Louie